Table of Contents
Previous Section
This section summarizes the WebScript language.
WebScript includes the following reserved words:
if else for while id break continue nil YES/NO persistent session action
WebScript supports the following statements:
if else for while break continue returnIn WebScript these statements behave as they do in the C language.
WebScript supports the arithmetic operators +, - , /, *, and %. The rules of precedence in WebScript are the same as those for the C language. You can use these operators in compound statements such as:
b = (1.0 + 3.23546) + (((1.0 * 2.3445) + 0.45 + 0.65) - 3.2);
WebScript supports the negation (!), AND (&&), and OR (||) logical operators. You can use these operators as you would in the C language, for example:
if ( !(!a || a && !i) || (a && b) && (c || !a && (b+3)) ) i = 0;
WebScript supports the relational operators <, <=, >, >=, ==, and !=.
In WebScript these operators behave as they do in C.
WebScript supports the ++ and -- operators. These operators behave as they do in the C language, for example:
// Use myVar as the value of the expression and then increment myVar myVar++; // Increment myVar and then use its value as the value of the expression ++myVar;
WebScript only supports one data type: objects (ids). The id type is defined as a pointer to an object---in reality, a pointer to the object's data (its instance variables). Like a C function or an array, an object is identified by its address. All objects, regardless of their instance variables or methods, are of type id.
In WebScript, self is available in every method. It refers to the object (either the WOApplication object or the WOWebScriptComponentController object) associated with a script. When you send a message to self, you're telling the object associated with the script to perform a method that's implemented in the script.
The persistent keyword is used in a component script to identify a variable whose state is maintained for the duration of the current session (as opposed to transaction variables, which cease to exist at the end of a transaction).
The session keyword is used in an application script to identify a variable whose state is maintained for the duration of an application, and of which every session has its own version (as opposed to global variables, which has the same value in all sessions).
The action keyword is used in a child component script to identify a WOAction object that the parent component associates with a method.
WOApp is a global variable that provides a shorthand for the following statement:
[WOApplication sharedObject];
This statement returns the single WOApplication object that is accessed by all users of an application.